<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>140-动画-顶部固定.html</title>
	<style>
		*{
			margin: 0;
			padding: 0;
		}
		.top{
			/*width: 500px;*/
			height: 100px;
			background-color:#ccc;
		}
		#nav{
			position: fixed;
			top: 0;
			left: 50%;
			margin-left: -630px;
			width: 1260px;
			height: 100px;
			background-color: yellow;
		
		}
		.main{
			height: 2000px;
		
			background:skyblue;
		}
	</style>
</head>
<body>
	<div class="top"></div>
	<div id="nav"></div>
	<div class="main"></div>
</body>
<script src="js/util.js"></script>
<script>
	var oNav = document.getElementById('nav');
	var isShow = false;
	window.onscroll = function(){
		if(getScrollTop() >= 100){
			if(!isShow){
				animate(oNav,"height",100);
				isShow = true;
			}
			
			}else{
				if(isShow){
				animate(oNav,"height",0);
				isShow = false;
				}
			}
		}
</script>
</html>